#include "H264StreamPubSubTypes.h"
#include "shm_participant.h"
#include "default_publisher.h"
//#include "sensor_msgs/msgs/Mocap.h"
#include <chrono>
#include <cstdlib>
#include <future>
#include "DDSPIM.h"

int main() {
  // Message
  vis_msg::H264Stream h264Stream;
  h264Stream.id(1);
  h264Stream.name("hello hi!!!");
  h264Stream.channelNumber(1);

  // Create participant. Arguments-> Domain id, QOS name
  ShmParticipant dp(AODS_I7_MAIN_0, "hi");

  // Create publisher with msg type
  DDSPublisher hello_pub(vis_msg::H264StreamPubSubType(), AODS_1126_OBJ_L,dp.participant());

  //DefaultParticipant dp;
  //dp.init(0, "hi");

  //DDSPublisher<vis_msg::H264StreamPubSubType>  hello_pub;

  //hello_pub.init("h2644",dp.participant());


  // Initialize publisher with topic name
  //if (hello_pub.init("h2644",dp.participant())) {
    for (int i = 0; i < 1000; i++) {
      h264Stream.id(i + 1);
      h264Stream.channelNumber(i + 1);
      hello_pub.publish_wait(h264Stream,0);
      std::this_thread::sleep_for(std::chrono::milliseconds(1000));
      std::cout <<"id:" << h264Stream.id() << "---"<<h264Stream.name()<<" --- "<<h264Stream.channelNumber() <<std::endl;
    }
  //}

  // eprosima::fastdds::dds::DomainParticipantFactory::get_instance()
  //     ->delete_participant(participant_);
}
